package com.example.common.provider3.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.example.common.provider3.handler.CommonBackHandler;
import com.example.common.provider3.handler.ResourceKey;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

/**
 * @author wangjinlong
 * @date 2022/2/15 17:12
 */
@RefreshScope
@Component
public class Provider3Service {

    @Value("${api.common.config:0}")
    private Integer config;

    @SentinelResource(
            value = ResourceKey.KEY_STORE,
            blockHandlerClass = CommonBackHandler.class, blockHandler = "handleBlockException",
            fallbackClass = CommonBackHandler.class, fallback = "handleAllException"
    )
    public String get(){
//        int a = 10/0;
        return "I'm provider 3 config = " + config;
    }

}
